package com.gdface.face.greendao_test;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;



public class MainActivity extends AppCompatActivity implements View.OnClickListener {

    private Button add,del,mod,find;
    private EditText et;
    private int sum = 0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        initView();
    }

//    private UserDao dao;
    private void initView() {
//        dao = GDUtils.getInstance().getDaoSession(MainActivity.this).getUserDao();

        add = (Button) findViewById(R.id.add_bt);
        del = (Button) findViewById(R.id.del);
        mod = (Button) findViewById(R.id.mod);
        find = (Button) findViewById(R.id.find);

        add.setOnClickListener(this);
        del.setOnClickListener(this);
        mod.setOnClickListener(this);
        find.setOnClickListener(this);

        et = (EditText) findViewById(R.id.editText);
    }


    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.add_bt:
                sum++;
                String age = et.getText().toString().trim();
//                User user = new User(null,"小明"+sum,age,(sum%2 == 0)? "男":"女","6000");
//
//                dao.insert(user);
                break;

            case R.id.del:
//                Long key = Long.parseLong(et.getText().toString().trim());
//                dao.deleteByKey(key);
                break;

            case R.id.mod:
//                Long keymod = Long.parseLong(et.getText().toString().trim());
                Log.i("hwwlog","update id ==>"+sum);
                Long keymod = Long.parseLong(String.valueOf(sum));
//                User userload = dao.load(keymod);
//                User usermod = new User(userload.getId(),userload.getName(),userload.getAge(),userload.getSex(),"10000");
//                dao.update(usermod);
                break;

            case R.id.find:
//                List<User> list =  dao.loadAll();
//                for(int i = 0; i<list.size();i++){
//                    Log.i("hwwlog",list.get(i).toString());
//                }
                break;
        }
    }
}
